package com.zxl.live.screen.ui.helper;

import android.content.Context;
import android.content.SharedPreferences;

import com.zxl.live.screen.screen.constant.ISharedPreferences;

/**
 * SP管理器(新版)
 *
 * @author linzewu
 * @date 16-8-17
 */
public class SpManager {

    private static SpManager sInstance;

    public synchronized static SpManager getInstance(Context context) {
        if (sInstance == null) {
            sInstance = new SpManager(context.getApplicationContext());
        }
        return sInstance;
    }

    private SpManager(Context context) {
        mSharedPreferences = context.getSharedPreferences(ISharedPreferences.SP_DEFAULT_MAIN_PROCESS, Context.MODE_PRIVATE);
    }

    private SharedPreferences mSharedPreferences;

    /**
     * 设置主动弹框显示弹框的逻辑
     *
     * @return
     */
    public int getAutoGuideMode() {
        return mSharedPreferences.getInt(ISharedPreferences.KEY_AUTO_GUIDE_SHOW_MODE, 0);
    }

    /**
     * 获取主动弹框显示弹框的逻辑
     *
     * @param mode
     */
    public void setAutoGuideMode(int mode) {
        mSharedPreferences.edit().putInt(ISharedPreferences.KEY_AUTO_GUIDE_SHOW_MODE, mode).commit();
    }

    /**
     * 设置主动引导弹框是否需要展示
     *
     * @param isNeedAutoShow
     */
    public void setIsAutoGuideNeedShow(boolean isNeedAutoShow) {
        mSharedPreferences.edit().putBoolean(ISharedPreferences.KEY_IS_AUTO_GUIDE_NEED_SHOW, isNeedAutoShow).commit();
    }

    /**
     * 返回主动引导弹框是否需要展示
     *
     * @return
     */
    public boolean getIsAutoGuideNeedShow() {
        return mSharedPreferences.getBoolean(ISharedPreferences.KEY_IS_AUTO_GUIDE_NEED_SHOW, false);
    }

    /**
     * 设置双开功能是否已经使用过
     *
     * @param hasUse
     */
    public void setHasDoubleAppUse(boolean hasUse) {
        mSharedPreferences.edit().putBoolean(ISharedPreferences.KEY_HAS_DOUBLE_APP_USE, hasUse).commit();
    }

    /**
     * 返回双开功能是否已经使用过
     *
     * @return
     */
    public boolean getHasDoubleAppUse() {
        return mSharedPreferences.getBoolean(ISharedPreferences.KEY_HAS_DOUBLE_APP_USE, false);
    }
}
